class Solution
{
public:
    long long maxScore(vector<int> &nums, int x)
    {
        long long dOdd = nums[0];
        long long dEven = nums[0];

        if (nums[0] & 1)
        {
            dEven -= x;
        }
        else
        {
            dOdd -= x;
        }

        for (int i = 1; i < nums.size(); ++i)
        {
            if (nums[i] & 1)
            {
                dOdd = max(dOdd + nums[i], dEven + nums[i] - x);
            }
            else
            {
                dEven = max(dEven + nums[i], dOdd + nums[i] - x);
            }
        }
        return max(dOdd, dEven);
    }
};